#pragma once
#include "DrawView.h"
#include "UIdef.h"
#include "IUIDialog.h"
#include <vector>
namespace UILib
{
    typedef struct PopupCustomObserver : public DialogCustomObserver{
        virtual bool GetWindowStytle(DWORD& dwStytle, DWORD& dwExstytle){
            dwStytle = WS_POPUP;
            dwExstytle = WS_EX_TOPMOST & ~WS_EX_APPWINDOW | WS_EX_TOOLWINDOW;
            return true;
        };
    }PopupCustomObserver, * PPopupCustomObserver;

    class CDrawComboBox : public CDrawView\
        , BaseListListener
    {
    public:
        CDrawComboBox(void);
        CDrawComboBox(HWND hWnd, Bitmap* pBitmap,  Bitmap* pIcon, const PUIRect pRect\
            , const PSplitPos pSplit = NULL, const UINT uID = -1, const int nStatusCount = 4\
            , ViewListener* pListener = NULL);
        virtual ~CDrawComboBox(void);

        wstring GetClass() { return L"CComboBox"; };

        void AppendText(const wstring wszText);
        void Erase(const int nIndex);
        void Clear();

        void SetSel(const int nSel);
        int  GetSel() const { return m_nSel;};

        void SetTextColor(const COLORREF cl, const COLORREF clSel = 0XFFFFFF );
        void SetTextFont(const LOGFONT& lf);

        void SetDropDownInfo( const COLORREF clBkg, const COLORREF clHover, Bitmap* pScrollBtn );

        virtual void HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, HWND hWnd, BOOL& bHandled );
        virtual void DrawElement( const HDC hDC, const RECT &rcPaint );

        virtual void OnSelChanged( const UINT uorgMsg, const int nSel, const int uID, const bool bSel, void* vData );
    protected:
        void OnClick();
        void CreateDropDownDlg( RECT& rc );
    private:
        HWND                m_hWnd;
        int                 m_StatusCount;
        Bitmap*             m_pBitMap;
        Bitmap*             m_pArrow;
        SplitPos            m_szSplit;

        vector<wstring>     m_vecItem;
        int                 m_nSel;

        COLORREF            m_color;
        COLORREF            m_colorSel;
        LOGFONT             m_lf;

        COLORREF            clListbkg_;
        COLORREF            clListHover_;
        Bitmap*             bmpScroll_;

        IUIDialog*          m_pComDlg;
    };
}
